2023-11-13
절댓값 힙
https://www.acmicpc.net/problem/11286
최소값 출력 후 제거
abs(value) - value를 절대값으로 변경 (-2 => 2)
import sys import heapq input = sys.stdin.readline n = int(input()) array = [] for _ in range(n): x = int(input()) if x == 0: if array: _, value = heapq.heappop(array) print(value) else: print(0) else: heapq.heappush(array, (abs(x), x))
